//
//  MMWDHPhotoBrowser.h
//  MMWPT
//
//  Created by 高得华 on 2018/12/12.
//  Copyright © 2018年 高得华. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "HXPhotoManager.h"

@class LFResultObject, HXPhotoModel;

UIKIT_EXTERN NSString * _Nullable const kMMWDHPhotoBrowserFileListTempExtension;
UIKIT_EXTERN NSString * _Nullable const kMMWDHPhotoBrowserPhotoBrower;
UIKIT_EXTERN NSString * _Nullable const kMMWDHPhotoBrowserSaveImageFailureReason;
UIKIT_EXTERN NSString * _Nullable const kMMWDHPhotoBrowserSaveImageSuccessMessage;
UIKIT_EXTERN NSString * _Nullable const kMMWDHPhotoBrowserSaveImageFailureMessage;

typedef void(^GEdwardLFPBCSuccessBlock)(void);
typedef void(^GEdwardLFPBCFailureBlock)(NSError * _Nullable error);
typedef void(^GEdwardLFPBCDownloadBlock)(long long totalBytes,long long totalBytesExpected);

///选择照片之后的回调 第一帧图片数组 原有的信息
typedef void(^kBlockMMWDHPhotoBrowserSelect)(NSArray<LFResultObject *> * __nullable results);

///枚举 选择图片、视频 或者两者的枚举
typedef NS_ENUM(NSInteger, MMWDHPhotoBrowserSelectEnum) {
    ///图片 视频 都包含
    kMMWDHPhotoBrowserSelectEnumDefault = 0,
    ///只是图片 live photo等
    kMMWDHPhotoBrowserSelectEnumPhoto   = 1,
    ///只是视频
    kMMWDHPhotoBrowserSelectEnumVideo   = 2,
};



//MARK: ==== 图片 视频的编辑管理者
@interface MDHPhotoVideoEditManager : NSObject

///初始化数据
+ (MDHPhotoVideoEditManager * _Nonnull)manager:(HXPhotoManager * _Nullable)manager;

///相册的管理者
@property (nonatomic, strong, readonly) HXPhotoManager * _Nullable manager;

@end


//MARK: 选择 图片 、 视频的属性类
@interface MMWDHPhotoBrowserSelectModel : NSObject

///选择类型的枚举 默认 都会选择
@property (nonatomic, assign) MMWDHPhotoBrowserSelectEnum allow;
///是否展示 预览视图 默认true
@property (nonatomic, assign) BOOL preview;
///最大选择数 默认1张
@property (nonatomic, assign) NSInteger maxCount;
///允许选择视频的最大时长，单位：秒， 默认 120s
@property (nonatomic, assign) NSInteger maxVideoDuration;
///最大录制时长，默认 15s，最小为 1s
@property (nonatomic, assign) NSInteger maxRecordDuration;
///拍摄 或者 选择 Camera or album 默认是相册
@property (nonatomic, assign) BOOL isCamera;

///默认的编辑
@property (nonatomic, assign) MDHPhotoVideoEditManager * _Nullable edit;
///相册的管理者
@property (nonatomic, strong) HXPhotoManager * _Nullable manager;
///是否用户x头像 - 需要进行裁剪
@property (nonatomic, assign) BOOL isAvatar;

@end



NS_ASSUME_NONNULL_BEGIN

///图片选择、浏览器 
@interface MMWDHPhotoBrowser : NSObject

///单例
+ (MMWDHPhotoBrowser *)shared;

/**
 展示视图
 
 @param items 视频、图片地址 图片
 @param index 选中的哪个
 */
- (void)showPhoto:(NSArray *)items index:(NSInteger)index;

//MARK: 选择照片
///选择照片 视频
- (void)selectVideoPhoto:(MMWDHPhotoBrowserSelectModel *)model block:(kBlockMMWDHPhotoBrowserSelect)block;
- (void)showBrowser:(MMWDHPhotoBrowserSelectModel *)model block:(void(^)(NSArray <HXPhotoModel *>*))block;

///对单张图片进行剪切
- (void)cutIntoPhoto:(UIImage *)image block:(void(^)(UIImage *))block;


#pragma mark - 将相片存入相册, 只回调这个方法
///将图片保存到相册
- (void)saveALAssetsLibrary:(UIImage * _Nullable)image;
///下载网址的 Library
- (void)downloadWithUrl:(NSString *)url;


#pragma mark ====== 常用函数 ======
///获取下载地址路径
- (NSString *)getDLTempPathWithSavePath:(NSString *)path;
///判断当前的文件是否已经下载了
- (BOOL)isExistsDL:(NSString *)url;
///取消某个下载地址
- (void)cancelDL:(NSString *)url;
///取消全部的下载
- (void)cancelAllDL;
///开启下载
- (void)basicHttpFileDownloadWithUrlString:(NSString *)aUrlString
                                    offset:(u_int64_t)offset
                                    params:(NSDictionary *)aParams
                                   timeout:(NSTimeInterval)timeout
                                  savePath:(NSString *)aSavePath
                                  download:(GEdwardLFPBCDownloadBlock)aDownload
                                   success:(GEdwardLFPBCSuccessBlock)aSuccess
                                   failure:(GEdwardLFPBCFailureBlock)aFailure;


@end

NS_ASSUME_NONNULL_END





